#ifndef MULTI_LIST_WIDGET_H
#define MULTI_LIST_WIDGET_H

#include <QWidget>
#include <QStyledItemDelegate>

class CmbBoxItemDelegate : public QStyledItemDelegate
{
    Q_OBJECT

public:
    CmbBoxItemDelegate(QObject *parent = nullptr);

    void setBackBrush(const QVariant& color)
    {
        m_backColor = color;
    }
protected:
    QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
    void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const;
    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
    bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override;
    void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &/* index */) const;
    QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;

signals:
    void signal_btn_clicked(const QModelIndex& index);
private:
    QVariant m_backColor{ QVariant() };
    QPoint m_point{ QPoint(0, 0) };
};

class QStandardItemModel;
namespace Ui
{
    class MultiListWidget;
};

class MultiListWidget : public QWidget
{
	Q_OBJECT

public:
    MultiListWidget(QWidget *parent = nullptr);
    ~MultiListWidget();

    void addItem(const QString& text, const QVariant& userData);

    void setData(const QVariant& data);

    QVariant data() const;

private:
	void initPage();
	
signals:
    void signal_text(const QString& text);

private:
    Ui::MultiListWidget *ui;
	QStandardItemModel* m_pModel{ nullptr };
    QString m_text{ QString() };
};

#endif //MULTI_LIST_WIDGET_H
